Attribute VB_Name = "Module4"
Option Explicit

Sub Initall(mControl As Control, ComBox As Control)
    
'    Select Case gHosCode
'        Case NC2
'        Case Else
        
            Dim WardsNum As Integer
            Dim i As Integer
            Dim swards
            Call Restore_Connect(mControl)
            mControl.Code = "$$GETWARD^DHCSTCODEMAINTAIN()"
            mControl.ExecFlag = 1
            If mControl.Value <> "" Then
               WardsNum = mControl.Value
            Else
               WardsNum = 0
            End If
            If WardsNum > 0 Then
                    
                Call PLISTtoCb(mControl, ComBox)

'                For i = 1 To WardsNum
'                    Call Restore_Connect(mControl)
'                    mControl.P0 = i
'                    mControl.Execute "$$ListGeneric^DHCSTCODEMAINTAIN(P0)"
'                    If VismErr(mControl) < 0 Then
'                        Exit Sub
'                    End If
'                    ComBox.AddItem mControl.Value
'               Next i
            End If
'    End Select
End Sub
Sub PLISTtoCb(v As VisM, cb1 As ComboBox)
    Dim X As Integer
    Dim sTest() As String
    Dim locnum As Integer
    Dim i As Integer
    
    Const cnt = 50
    X = 0
    Do
        v.P0 = X
        v.P1 = cnt
        v.Execute "$$PiecePLIST^DHCSTCODEMAINTAIN(P0,P1)"
        If VismErr(v) < 0 Then Exit Sub
        If v.PLIST = "" Then Exit Sub
        sTest = Split(v.PLIST, v.PDELIM)
        locnum = UBound(sTest)
        For i = 0 To locnum
            cb1.AddItem sTest(i)         ', i
        Next i
        If Val(locnum + 1) < cnt Then Exit Do
        X = X + cnt
    Loop
End Sub




Sub Initall2(mControl As Control, ComBox As Control)
    Dim WardsNum As Integer
    Dim i As Integer
    Dim swards
    mControl.Code = "$$GETWARD2^DHCSTCODEMAINTAIN()"
    mControl.ExecFlag = 1
    If mControl.Value <> "" Then
       WardsNum = mControl.Value
    Else
       WardsNum = 0
    End If
    If WardsNum > 0 Then
       swards = Split(mControl.PLIST, "^")
        ComBox.AddItem ""
       For i = 0 To WardsNum - 1
           If swards(i) <> "" Then ComBox.AddItem swards(i)
       Next i
    End If
End Sub
Sub Initall3(mControl As Control, ComBox As Control, name As String)
    Dim WardsNum As Integer
    Dim i As Integer
    Dim swards
    mControl.P0 = name
    mControl.Code = "$$GETZI^DHCSTCODEMAINTAIN(PO)"
    mControl.ExecFlag = 1
    MsgBox mControl.Value
    If mControl.Value <> "" Then
       WardsNum = mControl.Value
    Else
       WardsNum = 0
    End If
    If WardsNum > 0 Then
        swards = Split(mControl.PLIST, "^")
         ComBox.AddItem ""
        For i = 0 To WardsNum - 1
            If swards(i) <> "" Then ComBox.AddItem swards(i)
        Next i
    End If
End Sub
